var recIndexCtrl = myApp.controller('recIndexCtrl', ['$scope', '$rootScope', function($scope, $rootScope) {
	$rootScope.firstType = Tools.permissionList[0].permissionId;
	$rootScope.secondType = Tools.permissionList[0].sonPermission[0].permissionId;
	// 初始化
	function init() {
		$(document).ready(function() {
			setEchart1();
			setEchart2();
			setEchart3();
			setEchart4();
		});
	}
	init();

	// 柱状图-招生目标
	function setEchart1() {
		var echart = document.getElementById('echart1');
		var myChart = echarts.init(echart);
		var option = {
			tooltip: {
				trigger: 'axis',
				type: 'shadow'
			},
			legend: {
				data: ['目标数', '实际完成数']
			},
			grid: {
			    left: '3%',
		        right: '4%',
		        bottom: '3%',
		        containLabel: true
		    },
		    xAxis: [
		        {
		            type : 'category',
		            data : ['201609', '201611', '201701'],
		            axisTick: {
		                alignWithLabel: true
		            }
		        }
		    ],
		    yAxis: [
		        {
		            type : 'value'
		        }
		    ],
		    series : [
		        {
		            name:'目标数',
		            type:'bar',
		            data:[0.5, 0.8, 0.7]
		        }, {
		        	name:'实际完成数',
		            type:'bar',
		            data:[0.3, 0.4, 0.5]
		        }
		    ]
		};
		myChart.setOption(option);
	}

	// 漏斗图-招生漏斗
	function setEchart2() {
		var echart = document.getElementById('echart2');
		var myChart = echarts.init(echart);
		var option = {
		    tooltip: {
		        trigger: 'item',
		        formatter: "{a} <br/>{b} : {c}%"
		    },
		    // toolbox: {
		    //     feature: {
		    //         dataView: {readOnly: false},
		    //         restore: {},
		    //         saveAsImage: {}
		    //     }
		    // },
		    legend: {
		        data: ['待定','机会','意向','入园','本月入园', '本月放弃']
		    },
		    calculable: true,
		    series: [
		        {
		            name:'漏斗图',
		            type:'funnel',
		            left: '10%',
		            top: 60,
		            bottom: 60,
		            width: '80%',
		            min: 0,
		            max: 100,
		            minSize: '0%',
		            maxSize: '100%',
		            sort: 'descending',
		            gap: 2,
		            label: {
		                normal: {
		                    show: true,
		                    position: 'inside'
		                },
		                emphasis: {
		                    textStyle: {
		                        fontSize: 20
		                    }
		                }
		            },
		            labelLine: {
		                normal: {
		                    length: 10,
		                    lineStyle: {
		                        width: 1,
		                        type: 'solid'
		                    }
		                }
		            },
		            itemStyle: {
		                normal: {
		                    borderColor: '#fff',
		                    borderWidth: 1
		                }
		            },
		            data: [
		                {value: 12, name: '待定'},
		                {value: 33, name: '机会'},
		                {value: 24, name: '意向'},
		                {value: 24, name: '入园'},
		                {value: 1, name: '本月入园'},
		                {value: 45, name: '本月放弃'}
		            ]
		        }
		    ]
		};
		myChart.setOption(option);
	}

	// 扇形图-渠道分析
	function setEchart3() {
		var echart = document.getElementById('echart3');
		var myChart = echarts.init(echart);
		///*
		var option = {
		    tooltip: {
		        trigger: 'item',
		        formatter: "{a} <br/>{b}: {c} ({d}%)"
		    },
		    // legend: {
		    //     orient: 'vertical',
		    //     x: 'left',
		    //     data:['潜在生来源', '口碑推荐', '其他']
		    // },
		    series: [
		        {
		            name:'潜在生来源',
		            type:'pie',
		            // selectedMode: 'single',
		            radius: [0, '30%'],

		            label: {
		                normal: {
		                    position: 'inner'
		                }
		            },
		            labelLine: {
		                normal: {
		                    show: false
		                }
		            },
		            data:[
		                {value:25, name:'潜在生来源'},
		            ]
		        },
		        {
		            name:'潜在生来源',
		            type:'pie',
		            radius: ['40%', '55%'],

		            data:[
		                {value:335, name:'口碑推荐'},
		                {value:102, name:'其他'}
		            ]
		        }
		    ]
		};
		myChart.setOption(option);
	}

	// -放弃原因分析
	function setEchart4() {

	}

}]);